package org.tloss.games.mummy;

import java.io.IOException;
import java.io.OutputStream;

public class DataWriter {
	StringBuffer buffer = new StringBuffer();

	public void save(OutputStream outputStream) throws IOException {
		outputStream.write(buffer.toString().getBytes());
		outputStream.flush();
	}

	public void set(int data) {
		String tmp = String.valueOf(data);
		set(tmp);
	}

	public void set(String data) {
		String tmp1 = String.valueOf(data.length());
		for (int i = 0; i < 3 - tmp1.length(); i++) {
			buffer.append("0");
		}
		for (int i = 0; i < tmp1.length() && i < 3; i++) {
			buffer.append(tmp1.charAt(i));
		}
		buffer.append(data);
	}
}
